namespace my_bitset
{
	template<size_t N>
	class bitset
	{
	public:

		bitset() { _bits.resize(N * 8 + 1); }

		void set(size_t x)
		{
			size_t i = x / 8;
			size_t j = x % 8;

			_bits[i] |= (1 << j);
		}

		void reset(size_t x)
		{
			size_t i = x / 8;
			size_t j = x % 8;

			_bits[i] &= ~(1 << j);
		}

		bool test(size_t x)
		{
			size_t i = x / 8;
			size_t j = x % 8;

			return _bits[i] & (1 << j);
		}

	private:
		vector<char> _bits;
	};

	template<size_t N>
	class twobitset
	{
	public:
		void set(size_t x)
		{
			bool bo1 = _bit1.test(x);
			bool bo2 = _bit2.test(x);

			if (bo1 == false && bo2 == false)
			{
				_bit2.set(x);
			}
			else if (bo1 == false && bo2 == true)
			{
				_bit1.set(x);
				_bit2.reset(x);
			}
			else if (bo1 == true && bo2 == false)
			{
				_bit1.set(x);
				_bit2.set(x);
			}
		}

		void print_once_num()
		{
			for (size_t i = 0; i < N; ++i)
			{
				if (_bit1.test(i) == false && _bit2.test(i) == true)
				{
					cout << i << endl;
				}
			}
		}

	private:
		bitset<N> _bit1;
		bitset<N> _bit2;
	};

	void test_bit_set3()
	{
		int a[] = { 3, 4, 5, 2, 3, 4, 4, 4, 4, 12, 77, 65, 44, 4, 44, 99, 33, 33, 33, 6, 5, 34, 12 };

		twobitset<100> bs;
		for (auto e : a)
		{
			bs.set(e);
		}
		cout << endl;
		bs.print_once_num();
	}
}
